Release 10.1A: OpenEdge Development:
Progress 4GL Reference
INTERFACE statement
Defines an interface. An interface is a special type of class definition that contains a set of method prototype declarations for common methods implemented by one or more classes. All classes that implement the interface must support the methods declared in the interface.
Note: This statement is applicable only when used in a class definition (.cls) file.Syntax
type-nameA character string that specifies the type name of an interface. Specify an interface type name using the
package.class-namesyntax as described in the Type-name syntax reference entry in this book.interface-bodyThe body of an interface definition is composed of the following types of elements:
Example
- Temp-table or ProDataSet object definitions used as parameters by one or more methods whose prototype is declared in this interface.
- Method prototypes for common methods implemented by one or more classes.
Define elements in the interface body using the following syntax:
temp-table|datasetSpecifies one or more temp-table or ProDataSet object definitions used as parameters by one or more methods declared in this interface. You must specify these object definitions before any method prototypes. Progress does not allocate memory for these object definitions. You cannot specify an access mode for these object definitions.
The definition of temp-table and ProDataSet object parameters for methods defined in any classes that implement this interface must match the temp-table or ProDataSet object definitions in this interface.
For temp-table objects:
- The temp-tables must have the same number of fields, and each field must match with respect to the data type, extent, and position. Neither the table names nor field names must match.
- The temp-tables must have the same number of indexes, and each index component must match, including the index names. However, the index-component field names do not need to match.
For ProDataSet objects:
- The ProDataSet objects must have the same number of member buffers, and the buffers must be in the same order. Neither the buffer names nor ProDataSet names must match.
- The temp-tables of these buffers must match as described above.
method-prototypesSpecifies one or more method prototypes in the interface. A method prototype declares a method in the class without implementing the method (that is, without specifying the method’s logic or the END METHOD statement). You must specify a method prototype with a PUBLIC access mode. For more information, see the METHOD statement reference entry in this book.
The implementation of these method prototypes, in other classes that implement this interface, must match these declarations with respect to the access mode of the method and its return type, and with respect to the number, data type, and access mode of any parameters.
END [ INTERFACE ]Specifies the end of the interface body definition. You must end the interface body definition with the END statement.
The following example shows the definition of an interface that declares two method prototypes:
The following example shows the definition of a class that implements this interface and its method declarations:
Notes
- You can terminate an INTERFACE statement with either a period (.) or a colon (:).
- A complete interface definition must begin with the INTERFACE statement and end with the END statement.
- The access mode for an interface definition is always PUBLIC.
- A class definition (
.cls) file can contain only one interface definition.- The compiled version of an interface definition file is an r-code (
.r) file.- You can define an object reference variable for an interface, which lets you access the interface or a class that implements the interface, but you cannot create an instance of an interface with the NEW statement. Instead, create an instance of a class that implements the interface. For more information, see the AS CLASS option in the DEFINE VARIABLE statement reference entry in this book.
- You can reference include files from within an interface definition. For more information about include files, see the { } Include file reference entry in this book.
- All built-in preprocessor directives are supported in interface definitions.
- All built-in preprocessor names are supported in interface definitions. For a list of preprocessor name, see the { } Preprocessor name reference entry in this book.
- You cannot pass compile-time arguments to interface definition files. However, you can pass compile-time arguments to include files referenced in an interface definition file.
- You can store class definition r-code files in Progress procedure libraries. If Progress encounters a procedure library on
PROPATH, it will search the library for the specified r-code. However, you cannot execute r-code files stored in a procedure library that is not onPROPATHusing theprocedure-library-path<<member-name>> syntax.See also
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |